Skip to content

[api-major] Compress the binary CMap files with Brotli - #22513

Merged
timvandermeij merged 1 commit into
mozilla:masterfrom
Snuffleupagus:bcmaps-Brotli
Nov 12, 2026
Merged

timvandermeij merged 1 commit into
mozilla:masterfrom
Snuffleupagus:bcmaps-Brotli

Conversation

@Snuffleupagus

@Snuffleupagus Snuffleupagus commented Nov 12, 2026 •

Copy link
Copy Markdown
Collaborator

While the binary CMap format is fairly efficient already, by also compressing them maximally with Brotli we can reduce their size even further.
The decompression is done on load in the worker-thread, and thanks to the existing caching it only needs to happen once per file. By utilizing the BrotliStream class all builds/environments can use these smaller files, and in e.g. Firefox (which supports native decompression) even the largest binary CMap files are decompressed in under 1 millisecond.

Note: This reduces the size of the gulp mozcentral bundle by 320076 bytes, i.e. over 312 kilo-bytes.

@github-actions

github-actions Bot commented Nov 12, 2026 •

Copy link
Copy Markdown
Contributor

Reference tests

Results for 255be26 (run, references from mozilla/pdf.js.refs@15d1c1caf7).

Platform Status Tests Total runtime Errors Different FBF No reference Report
Linux ⚠️ 1420 13m 37s 0 1 0 0 view differences
Windows ✅ 1420 16m 8s 0 0 0 0

The report is kept for 30 days and replaced by the next run.

sync-pdfs-for-pdf-js Bot pushed a commit to mozilla/pdf.js.refs that referenced this pull request Nov 12, 2026
@github-actions

github-actions Bot commented Nov 12, 2026 •

Copy link
Copy Markdown
Contributor

Viewer preview

🗑️ Viewer previews removed.

@codecov-commenter

codecov-commenter commented Nov 12, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 90.38%. Comparing base (2b5c986) to head (06e4ecb).

Additional details and impacted files
@@            Coverage Diff             @@
##           master   #22513      +/-   ##
==========================================
- Coverage   90.56%   90.38%   -0.18%     
==========================================
  Files         276      276              
  Lines       68676    69898    +1222     
==========================================
+ Hits        62193    63177     +984     
- Misses       6483     6721     +238     
Flag Coverage Δ
fonttest 9.08% <ø> (ø)
integrationtest 71.20% <ø> (+1.53%) ⬆️
unittest 63.10% <ø> (+<0.01%) ⬆️
unittestcli 60.68% <ø> (+0.01%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

sync-pdfs-for-pdf-js Bot pushed a commit to mozilla/pdf.js.refs that referenced this pull request Nov 12, 2026
sync-pdfs-for-pdf-js Bot pushed a commit to mozilla/pdf.js.refs that referenced this pull request Nov 12, 2026
@codspeed

codspeed Bot commented Nov 12, 2026 •

Copy link
Copy Markdown

Merging this PR will degrade performance by 10.69%

1 note

ℹ️ This run is excluded from the branch history

This commit was force-pushed, so this run no longer appears in the branch's performance history.

❌ 2 regressed benchmarks
✅ 86 untouched benchmarks
⏩ 174 skipped benchmarks1

Warning

Please fix the performance issues or acknowledge them on CodSpeed.

Performance Changes

Benchmark BASE HEAD Efficiency
❌ getUnicodeRangeFor (bug1473809.pdf) 24 ms 26.9 ms -11.03%
❌ Autolinker.processLinks: 10 links in each of 1000 text items 56.3 ms 62.7 ms -10.34%

Tip

Investigate this regression by commenting @codspeedbot fix this regression on this PR, or directly use the CodSpeed MCP with your agent.


Comparing Snuffleupagus:bcmaps-Brotli (9d467dc) with master (2b5c986)

Open in CodSpeed

Footnotes

  1. 174 benchmarks were skipped, so the baseline results were used instead. If they were deleted from the codebase, click here and archive them to remove them from the performance reports. ↩

While the binary CMap format is fairly efficient already, by also compressing them maximally with Brotli we can reduce their size even further.
The decompression is done on load in the worker-thread, and thanks to the existing caching it only needs to happen *once* per file. By utilizing the `BrotliStream` class all builds/environments can use these smaller files, and in e.g. Firefox (which supports native decompression) even the largest binary CMap files are decompressed in *under* `1` millisecond.

*Note:* This reduces the size of the `gulp mozcentral` bundle by `320076` bytes, i.e. over 312 kilo-bytes.
sync-pdfs-for-pdf-js Bot pushed a commit to mozilla/pdf.js.refs that referenced this pull request Nov 12, 2026

@calixteman calixteman left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. Thank you.

@timvandermeij
timvandermeij merged commit c664370 into mozilla:master Nov 12, 2026
21 of 23 checks passed
sync-pdfs-for-pdf-js Bot pushed a commit to mozilla/pdf.js.refs that referenced this pull request Nov 12, 2026
@timvandermeij

Copy link
Copy Markdown
Collaborator

Good idea; thank you for implementing this!

@Snuffleupagus
Snuffleupagus deleted the bcmaps-Brotli branch November 12, 2026 21:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants